package com.wt.controller;

import com.wt.pojo.User;
import com.wt.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping
    public String findList(HttpServletResponse response, HttpServletRequest request){
        System.out.println("----------进入后台---------");
        List<User> users = userService.findUsers();
        System.out.println("user==="+users);
        try {
            response.sendRedirect(request.getContextPath()+"/user.jsp");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "user";
    }
}
